use nalgebra::{Point3, Vector2, Vector3};
use serde::{Deserialize, Serialize};

#[repr(C)]
#[derive(
    bytemuck::Pod, bytemuck::Zeroable, Clone, Copy, Debug, Serialize, Deserialize, Default,
)]
pub struct Vertex {
    position: Point3<f32>,
    texCoord: Vector2<f32>,
    normal: Vector3<f32>,
    tangent: Vector3<f32>,
    bitangent: Vector3<f32>,
}

impl Vertex {
    pub fn new(position: Point3<f32>, texCoord: Vector2<f32>, normal: Vector3<f32>) -> Self {
        Self {
            position,
            texCoord,
            normal,
            ..Default::default()
        }
    }

    pub fn from_position(x: f32, y: f32, z: f32) -> Self {
        Self {
            position: Point3::new(x, y, z),
            texCoord: Vector2::identity(),
            normal: Vector3::identity(),
            tangent: Vector3::identity(),
            bitangent: Vector3::identity(),
        }
    }

    pub fn with_tangent(mut self, tangent: Vector3<f32>) -> Self {
        self.tangent = tangent;
        self
    }

    pub fn with_bitangent(mut self, bitangent: Vector3<f32>) -> Self {
        self.bitangent = bitangent;
        self
    }
}
